<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- JSTL标签库是一个JSP标签的集合，封装了许多jsp应用程序通用的核心功能-->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!-- JSTL格式化标签 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/layui.css"/>
		<script src="${pageContext.request.contextPath}/js/jquery.min-2.1.1.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/layui-v2.6.13/layui/layui.js"></script>
		<style>
			.layui-form{
				margin-top: 30px;
				margin-left: 30px;
			}
		</style>

</head>
<body>
	<form class="layui-form">
<%-- 	 <c:forEach items="${list}" var="str"> --%>
	  <div class="layui-form-item">
	    <label class="layui-form-label">专业ID：</label>
	    <div class="layui-input-inline">
	      <input type="text" name="id" class="layui-input" value="${obj.id}">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">专业名称：</label>
	    <div class="layui-input-inline">
	      <input type="text" name="mName" class="layui-input" value="${obj.mName}">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">所属学院：</label>
	    <div class="layui-input-inline">
    	  <select name="cId">
	        <option value="">请选择学院</option>
			  <c:forEach items="${allColleges}" var="college">
			  	<option value="${college.id}">${college.cName}</option>
			  </c:forEach>
	      </select>
	    </div>
	  </div>

<%-- 	 </c:forEach> --%>
	</form>
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" style="width: 150px;" onclick="update()">更新</button>
	    </div>
	  </div>
</body>
<script>
	//更新专业信息
 	function update(){
		var params = $("form").serialize();
		console.info(params);
		$.ajax({
			url: "ma",
			data: params+'&m=updataMajor',
			type: "post",
			success: function(code){
				if(code == '1'){
					alert("更新成功");
				} else {	
					alert("更新失败");
				}
				//延迟关闭
				setTimeout(closeLayer(), 500);
			}
		});
	}
	
	function closeLayer(){
		//关闭弹出层
/* 		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index); */
		//刷新父页面
		window.parent.location.reload();
	} 
</script>
</html>